#include "soundmanager.h"

#include <fmod.h> 
#include <fmod.hpp>
#include "actor.h"

#include <conio.h>
#include <iostream>
#include <windows.h>


#include "audio.h"
#include "soundeffect.h"
#include "soundmusic.h"
#include <cmath>

using namespace core;

int main()
{
		//player starts at(0,0,0)
		Actor player;
		player.pos.x=0.0f;
		player.pos.y=0.0f;
		player.pos.z=0.0f;

		//item, vader boss at (10,0,-10)
		Actor actVader;
		actVader.pos.x=30.0f;
		actVader.pos.y=0.0f;
		actVader.pos.z=-30.0f;


		//get soundmanager
		BootPtr			boot = BootPtr( new Boot );
		boot->stereo = true;

		//
		core::SoundManager* s = core::SoundManager::GetInstance();
		s->Init( boot );
		


		//set listener, by vectors

	  Vector3 pos;
		pos.x=0;
		pos.y=0;
		pos.z=-30;

		Vector3 dir;
		dir.x=1;
		dir.y=0;
		dir.z=0;
		
		player.foward.x = 1;
		s->SetListener(player);
		

		
	

		SoundMusic lead;
		lead.LoadSound("./resources/sounds/lead.mp3");
		
		
		SoundMusic bass;
		bass.LoadSound("./resources/sounds/bass.mp3");

		SoundMusic bass2;
		bass2.LoadSound("./resources/sounds/bass4.mp3");
		

		SoundMusic drum;
		drum.LoadSound("./resources/sounds/drum.mp3");


		SoundMusic vocal;
		vocal.LoadSound("./resources/sounds/vocal.mp3");


		SoundEffect vader;
		vader.LoadSound( "./resources/sounds/vader.wav" );
		/*
		SoundEffect se;
		se.LoadSound( "./resources/sounds/vader.wav" );
		se.Play( pos );
		float t = 0.0f;
		float dt = 0.0f;
		*/
		while(true)
		{
				/*
				t += 0.0001f;
				pos.x = 30 * cos(t);
				pos.z = 30 * sin(t);
        /*/
				//s->SetListener(player);
				//s->SetMasterFxVolume( int(cos(t) * 100) );

				/*if( t > dt + 1.26f )
				{
						//se.Play( pos );
						//dt = t;
						//std::cout << "you spin me round round baby right round.... " << std::endl;
				}*/

				int key;

				if (_kbhit())
				{

						key = _getch();


						if(key=='1')
						{
								lead.Play( -1 );
						}

						if(key=='2')
						{
								//sm.Stop();
								bass.Play( -1 );
						}

						if(key=='3')
						{
								//sm.Pause();
								drum.Play( -1 );
						}

						if(key=='4')
						{
								//sm.Start();
								vocal.Play( -1 );
						}

						if(key=='5')
						{
								//sm.SetVolume(100);
								s->StopAllMusic();
						}

						if(key=='8')
						{
								//sm.SetVolume(100);
								s->SetMasterMusicVolume(5);
						}

						if(key=='6')
						{
								//sm.SetVolume(100);
								
								bass2.Play(-1);
								bass2.SetVolume(20);
						}


						if(key=='7')
						{
								//sm.SetVolume(100);
								vader.Play(pos);
								
						}


						
				}

				s->update();
		}
								

		system("pause");
		
}